#ifndef __111建材批发__
#define __111建材批发__

#include <iostream>
#include <vector>

using std::cout;
using std::endl;
using std::vector;
namespace Su
{
    //创建一个类模板
    template<size_t N>
    class bitset
    {
    public:
        bitset()
        {
            //如果n是31，说明从0存到31，对应一个int整形 0+1
            //如果n是32，说明从0存到32，需要两个int整形存储 1+1
            size_t size = N / 32 + 1;
            _a.resize(size);
        }
        //将指定比特位变1,其他位不变
        void set(size_t num)
        {
            size_t i = num / 32;
            size_t j = num % 32;
            //其他位或0，指定位或1
            size_t com = 1<<j;
            _a[i] |= com;
        }

        //将指定比特位变0,其他位不变
        void reset(size_t num)
        {
            size_t i = num / 32;
            size_t j = num % 32;
            //其他位与1，指定位与0
            size_t com = ~(1<<j);
            _a[i] &= com;
        }

        bool test(size_t num)
        {
            size_t i = num / 32;
            size_t j = num % 32;
            //其他位与0，指定位与1
            size_t com = 1<<j;
            _a[i] &= com;
            return _a[i];
        }
    private:
        vector<int> _a;
    };
}


#endif

